<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/include/taglib.jsp"%>
<html>
	<head>
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<meta charset="UTF-8">
		<title>共富网-红包</title>
		<link href="/game/redpack/css/redPacket.css" type="text/css"
			rel="stylesheet" />
		<script type="text/javascript" src="/v3/js/jquery-1.10.2.min.js"></script>
		<script type="text/javascript"
			src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
		<script type="text/javascript">
			var senvKey = '${param.senvKey}';
		</script>
	</head>
	<body>
		<div class="wztkjPopUpBox" style="display: none;">
			<div class="wztkjPopUpBoxMain">
				<div class="wztkjPopUpBoxContent1">
					<img src="/game/redpack/images/popUpBoxMark_03_06.png" />
				</div>
				<div class="wztkjPopUpboxBg">
					<div class="wztkjPopUpBoxContent2"></div>
					<div class="wztkjPopUpBoxContent3">
						<p class="wztkjPopUpboxP">
							取消
						</p>
						<p class="wztkjPopUpboxP1">
							确定
						</p>
						<div style="display: none;"></div>
					</div>
					<div class="wztkjPopUpBoxContent4" style="display: none;">
						确定
					</div>
				</div>
			</div>
		</div>

		<div class="robAfterMain">
			<div class="robAfterMTop">
				<div class="robAfterMTLowBg">
					<div class="robAfterMTLBContent">
						<div class="robAfterPortrait">
							<div class="robAfterContentTTop">
								<c:choose>
									<c:when test="${recordMap.envStatus == 2}">
										<h3>
											红包已抢光
										</h3>
									</c:when>
									<c:when test="${not empty recordMap}">
										<h3>
											恭喜你抢到了
										</h3>
										<p>
											<span>${recordMap.valMoney }</span>元
										</p>
									</c:when>
								</c:choose>
							</div>
							<div class="redPacketPMain rechargeHPMain">
								<div class="redPacketBorder">
									<c:choose>
										<c:when test="${not empty sWechatInfoMap}">
											<img src="${sWechatInfoMap.headimgurl }" />
										</c:when>
										<c:otherwise>
											<img src="/game/redpack/images/0.png" />
										</c:otherwise>
									</c:choose>
								</div>
							</div>
							<p class="robAfterPDescribe">
								<span class="robAfterPName">${sWechatInfoMap.nickname}的红包</span>
							</p>
							<c:if test="${not empty recordMap.valMoney}">
								<p class="robAfterLink">
									<a href="/redPackInit.do">已存入共富网账户，戳我立即使用</a>
								</p>
							</c:if>
						</div>
					</div>
				</div>
			</div>

			<div class="robAfterMbBottom">
				<div class="robAfterMbBContent">
					<c:choose>
						<c:when test="${redpackMap.env_status == 2}">
							${redpackMap.env_count }个红包共 ${redpackMap.env_type == 1 ? redpackMap.money * redpackMap.env_count:redpackMap.money  } 元，
							${redpackMap.wasteTime == 0 ? 1:redpackMap.wasteTime }分钟被抢光		
						</c:when>
						<c:otherwise>
							领取${redpackMap.has_count }/${redpackMap.env_count }个
						</c:otherwise>
					</c:choose>
				</div>
			</div>
			<div class="robAfterMbBContentList">
				<div id="gainlist">
				</div>
				<!-- 底部-余额可以分享给好友奥~ -->
				<div class="robAfterBintbBottom">
					<a href="/myredpacklist.do" class="robAfterMbBintContent">查看我的红包</a>

				</div>
			</div>
		</div>
		<input type="hidden" name="pageNo" value="1" id="pageNo" />
		<input type="hidden" name="totalpage" value="1" id="totalpage" />
		<script type="text/javascript" src="/game/redpack/js/jquery.hbalerts.js"></script>
		<script type="text/javascript" src="/v3/js/wechat-util.js"></script>
		<script type="text/javascript" src="/game/redpack/js/share.redpack.js"></script>
<script type="text/javascript">	
		var ajaxpageno = 0;
		function ajaxgainlist(pageno){
			if(pageno){
				ajaxpageno = pageno;
				var myurl = '/gainllredpackList.do?senvKey=${param.senvKey}&pageNo='+pageno;
				 $.ajax({
			         url: myurl,
			         type: "POST",
			         success: function(data) {
					 	$('#pageNo').val(data.pageNo);
     		 		 	$('#totalpage').val(data.totalpage);
					 	var htmlStr = '';
					 	var list = data.lists;
					 	if(data.pageNo <= 1){
					 		htmlStr += '<ul class="gPriceList" id="gPriceListUl">';
					 	}
					    if(list.length > 0){
					        for(var i=0,len=list.length;i<len;i++){
					        	htmlStr += '<li>';
					        	htmlStr += '<div class="hImage"><img src="' + list[i].headimgurl + '" width="50" height="50"/></div>';
					        	htmlStr += '<div class="nName-Time-Money"><div class="gTop">';
					        	htmlStr += '<div class="uName">' + list[i].nickname + '</div>';
					        	htmlStr += '<div class="gMoney">' + list[i].valMoney + '元</div>';
					        	htmlStr += '</div>';
					        	htmlStr += '<div class="gBottom">';
					        	htmlStr += '<div class="gTime">' + list[i].createTimeFormat + '</div>';
					        	if(list[i].isMax == 1){
					        		htmlStr += '<div class="gBest"><i class="icon-Best"></i>手气最佳</div>';	
					        	}
					        	htmlStr += '</div>';
					        	htmlStr += '</div>';
					        	htmlStr += '</li>';
					        }
					    }
					    
					    if(data.pageNo > 1){
					    	$('#gPriceListUl').append(htmlStr);
						}else{
							htmlStr += '</ul>';
							$('#gainlist').html(htmlStr);
					    }
			         }
			      });
			}
		}
		
		$(function() {
			ajaxgainlist(1);
			
			var hW = $(".hImage").width();
			var gW = $(".gPriceList").width();
			$(".nName-Time-Money").width(gW-hW-15);
			$(window).resize(function() {
				myWindowResize();
			})
			function myWindowResize() {
				var hW = $(".hImage").width();
				var gW = $(".gPriceList").width();
				$(".nName-Time-Money").width(gW-hW-15);
			}
		})
		
		$(window).scroll(function(){
			　　var scrollTop = $(this).scrollTop();
			　　var scrollHeight = $(document).height();
			　　var windowHeight = $(this).height();
			　　if(scrollTop + windowHeight == scrollHeight){
			　	var totalpage = $("#totalpage").val();
				var no = $("#pageNo").val();
				var pageno = parseInt(no)+1;
				if(ajaxpageno!=pageno){
					if(totalpage != no){
						ajaxgainlist(pageno);
					}
				}
			　　}
		});
	</script>
	</body>
</html>